package com.coolpad.job.device.dao;

import com.coolpad.job.device.dao.provider.GeoInfoProvider;
import com.coolpad.job.device.model.CityPartitionPO;
import com.coolpad.job.device.model.Point;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GeoInfoDao {

    @InsertProvider(type = GeoInfoProvider.class, method = "batchInsertPoint")
    int batchInsert(@Param("list") List<Point> pointList);

    @Insert("INSERT INTO t_geo_full_info (partition_id,lon,lat) VALUES(#{partitionId},#{lon},#{lat})")
    void insertPoint(@Param("partitionId") Long partitionId, @Param("lon")String lon, @Param("lat")String lat);

    @Insert("INSERT INTO t_china_city_partition (partition_id,province_id,province_name,city_id,city_name,county_id,county_name,town_id,town_name) " +
            "VALUES(#{partitionId},#{provinceId},#{provinceName},#{cityId},#{cityName},#{countyId},#{countyName},#{townId},#{townName})")
    void insertPartitionInfo(CityPartitionPO po);

    @InsertProvider(type = GeoInfoProvider.class, method = "batchInsertCity")
    int batchInsertPartition(@Param("list")List<CityPartitionPO> pos);

    @Select("select DISTINCT(county_id) from t_china_city_partition where province_name = #{provinceName} and county_id != 440305000000")
    List<String> findAdCode(@Param("provinceName") String provinceName);
}
